package BSQX_Bit;

import java.util.ArrayList;
import java.util.Scanner;

public class BSQX_3_27 {

    public static int fin(int a,int b){
        if (a % b == 0){
            return b;
        }else {
            return fin(b,a%b);
        }
    }
    public static void main4(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int a=scanner.nextInt();
        int b=scanner.nextInt();
        int ret=fin(a,b);
        System.out.println(a*b/ret);

    }
    public static void main3(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        String str[]=new String[n];
        for (int i = 0; i < n; i++) {
            str[i]=scanner.next();
        }
        boolean f1=Str_fun1(str,n);
        boolean f2=Str_fun2(str,n);
        if (f1 && f2){
            System.out.println("both");
        }else if (f1){
            System.out.println("lexicographically");
        }else if (f2){
            System.out.println("lengths");
        }else {
            System.out.println("none");
        }
    }
    public static boolean Str_fun1(String str[],int n){
        /*检测字典序排列*/

        for (int i = 0; i < n-1; i++) {
            if (str[i].compareTo(str[i+1]) > 0){
                return false;
            }
        }
        return true;
    }
    public static boolean Str_fun2(String str[],int n){
        /*检测长度排列*/
        for (int i = 0; i < n-1; i++) {
            if (str[i].length() > str[i+1].length()){
                return false;
            }
        }
        return true;
    }
    public static void main2(String[] args) {
        int a=6;
        System.out.println(a);
        System.out.println(a++);
        System.out.println(a);
        ArrayList<Integer> arrayList=new ArrayList<>();


    }
   /* static int c=6;
    static {
        c+=9;
    }
    public static void main(String[] args) {
     *//*   double x=3.0;
        int y=5;
        x /= --y;
        System.out.println(x);*//*
        System.out.println(c);

    }
    static {
        c/=3;
    }*/
}
